package com.creative.util;

import android.content.Context;
import android.util.AttributeSet;
import android.widget.RelativeLayout;

/**
 * Created by yinjialiang on 15-7-2.
 */
public class ResizeLayout extends RelativeLayout{
    public interface OnResizeListener
    {
        public void onResize(int w, int h, int oldw, int oldh);
    }

    private OnResizeListener mListener;

    public ResizeLayout(Context context) {
        super(context);
    }

    public ResizeLayout(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public ResizeLayout(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    public void setOnResizeListener(OnResizeListener listener)
    {
        mListener = listener;
    }

    @Override
    protected void onSizeChanged(int w, int h, int oldw, int oldh) {
        super.onSizeChanged(w, h, oldw, oldh);
        if(mListener != null)
        {
            mListener.onResize(w, h, oldw, oldh);
        }
    }
}
